package com.aaa.ms.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ fileName:RibbonLoadBalanceConfig
 * @ description:
 * @ author:zhz
 * @ createTime:2023/6/8 10:05
 * @ version:1.0.0
 */
@Configuration //相当于过去XML   里面<beans>
public class RibbonLoadBalanceConfig {

    /**
     * 配置负载均衡策略
     * @return
     */
    @Bean // Rule 规则 <bean id=iRule class=com.netflix.loadbalancer.IRule >    多态 父类引用指向子类对象
    public IRule  iRule(){
        //IRule iRule = new RoundRobinRule();
        //轮询
       return new RoundRobinRule();
       // 随机
       //return  new MyCustomRule();
       //按权重负载，响应速度快的，给更多请求
        //return new WeightedResponseTimeRule();
    }
}
